import * as types from './mutations_types'
module.exports = {
    //设置问卷信息

    [types.SET_SERVEYS_DATA](state, {
        data
    }) {
        state.tableData = data.lit;
        // console.log('SET_SERVEYS_DATA');
        state.tableData.forEach(function(info) {
            // console.log('--SET_SERVEYS_DATA--', info);
            // console.log('--SET_SERVEYS_DATA--', JSON.parse(info.answer));
            info.answer = JSON.parse(info.answer);
        }, this);
        // console.log(typeof(data.count));
        state.tableTotal = Number(data.count);
        // console.log(state.tableData);
    },
    //设置页码
    [types.SET_PAGE_INDEX](state, {
        newPageIndex
    }) {
        state.currentPage = newPageIndex;
    },

    //设置查询问卷条件
    [types.SET_SURVEY_SELECT_OPTIONS](state, {
        selectOptions
    }) {
        state.selectOptions = selectOptions;
    },
    //清空查询问卷条件
    [types.CLEAN_SURVEY_SELECT_OPTIONS](state) {
        state.selectOptions = {};
        state.selectData = {
            name: '',
            address: [],
            age: '',
            phone: '',
            etype: ''
        };
        // console.log(state.tableData);
    },

};